package com.aliyun.msg.controller;

import com.aliyun.msg.utils.SmsUtils;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
import com.aliyuncs.exceptions.ClientException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@RequestMapping
public class MsgController {

    @Autowired
    private SmsUtils smsUtils;

    @RequestMapping(value = "getSMS", method = RequestMethod.GET)
    public String getSMS() throws ClientException {
        SendSmsResponse sendSmsResponse = smsUtils.sendSms("13420686041", "999999");
        String code = sendSmsResponse.getCode();

        String message = sendSmsResponse.getMessage();
        String bizId = sendSmsResponse.getBizId();
        String requestId = sendSmsResponse.getRequestId();
        System.out.println(code+"   "+ bizId+"   "+ requestId+"   "+ message);
        return message;

    }
}
